<?php
/*
+--------------------------------------------------------------------------
|   AffiliStore 2
|   ========================================
|   Web: http://www.affilistore.com
|   Email: admin (at) affilistore (dot) com
|	License Type: AffiliStore 2 is NOT open source software and limitations apply 
|   Licence Info: Visit AffiliStore website and click on 'Licence'
+--------------------------------------------------------------------------
*/
if (eregi(".inc.php",$HTTP_SERVER_VARS['PHP_SELF']) || eregi(".inc.php",$_SERVER['PHP_SELF'])) {
	echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is forbidden.\r\n</body>\r\n</html>";
	exit;
}


// brand listing
$sql = sprintf("SELECT * FROM affiliSt_categories WHERE parent = %s ORDER BY name ASC",
				quote_smart($_GET['nc']));
$getNavBrands = mysql_query($sql, $databaseConnect) or die(mysql_error());
$navBrandList = mysql_fetch_assoc($getNavBrands);


$box_content = new XTemplate ("skins/".$configSkin['value']."/styleTemplates/subnavcategories.tpl");

if ($navBrandList['name'] != NULL) {

$countbrands = 0;
$brandvalues = array();



// create navigation from category and brond list
	do { 
	$theresult = $navBrandList['id'];
	if ($storedBrand != $theresult) {
	if ($theresult == $_GET['nb']) {
			$brandvalueonoff[$countbrands] = 'brandNavOn';
	} else {
			$brandvalueonoff[$countbrands] = 'brandNavOff';
	}
			
			if ($navOpt[7] == 1) {
			// html perma
			$brandlinkvalues[$countbrands] = $installDir['value'].'subcategories/'.$_GET['nc'].'/'.$theresult.'/'.$_GET['urltxt'].'/'.urltxt($navBrandList['name']).'.html';
			} else {
			// php link
			$brandlinkvalues[$countbrands] = $installDir['value'].'index.php?case=subcategories&nc='.$_GET['nc'].'&nb='.$theresult;
			}
			
			$brandvalues[$countbrands] = $navBrandList['name'];
			
			
			
			
	
	$storedBrand = $theresult;
	$countbrands++;
	} else {
	$theresult = ucwords(strtolower($navBrandList['id']));
	}
	
	} while ($navBrandList = mysql_fetch_assoc($getNavBrands));
		
		$tdtotal = $countbrands/4;
		$tdtotal = ceil($tdtotal);
		//echo $tdtotal;
		//exit;
		
		$counter = 0;
		for ($i=0; $i<$countbrands; $i++) {
				$box_content->assign("SUBFONTSTYLE",$brandvalueonoff[$i]);
				$box_content->assign("SUBLINKDATA",$brandlinkvalues[$i]);
				$box_content->assign("SUBDATA",$brandvalues[$i]);
					if ($counter == 0) {
					$box_content->assign("OPENBRANDTD",'<td align="left" valign="top">');
					$box_content->assign("CLOSEBRANDTD",'');
					$box_content->assign("CLOSEBRANDENDTD",'');
					} else if ($counter == $tdtotal) {
					$box_content->assign("OPENBRANDTD",'<td align="left" valign="top">');
					$box_content->assign("CLOSEBRANDTD",'</td>');
					$box_content->assign("CLOSEBRANDENDTD",'');
					$counter = 0;
					} else if ($i == $countbrands) {
					$box_content->assign("OPENBRANDTD",'');
					$box_content->assign("CLOSEBRANDTD",'');
					$box_content->assign("CLOSEBRANDENDTD",'</td>');
					$counter = 0;
					} else {
					$box_content->assign("OPENBRANDTD",'');
					$box_content->assign("CLOSEBRANDTD",'');
					}
				$counter++;
				$box_content->parse("subnavcategories.li");
		} 



			
$box_content->assign("TITLE","Refine Search");
$box_content->assign("SKIN",$configSkin['value']);
$box_content->parse("subnavcategories");
$box_content = $box_content->text("subnavcategories");
} else {
$box_content->parse("nosubnavcategories");
$box_content = $box_content->text("nosubnavcategories");
}
?>